--- %%NOBANNER%% -->
![]() | ![]() |
/*-------------------<-- Start of Description-->---------------------\ | To delete a global macro variable; | |---------------------<-- End of Description-->----------------------| |--------------------------------------------------------------------| |------------<-- Start of Files or Arguments Needed-->---------------| | Argument: | | macrovar: the name of the macro variable you want to delete; | | All global variables need to be delete, separated by a space; | |---------------<-- End of Files Arguments Needed-->-----------------| |--------------------------------------------------------------------| |------------------<-- Start of Files Created-->---------------------| | Example: | | %global color_int hascolor; | | %_delmvar_(color_int hascolor); | | Usage: %_delmvar_(macrovar); | \-------------------<-- End of Files Created-->---------------------*/ %macro _delmvar_/parmbuff; /*--------------------------------------------\ | Author: Duo Zhou; | | Created: 9-28-2001 9:12pm; | | Modified: 1-15-2002 9:32pm; | | Purpose: Delete a global Macro Variable; | \--------------------------------------------*/ %local _nvars_ _var_ _vars_ _mvars_ _mvar_ _uvars_ _tmplast_; %let _nvars_=0; %let _tmplast_=&syslast; %do %while(%length(%nrbquote(%qscan(%quote(&syspbuff), %eval(&_nvars_+1), %str( (),))))); %let _nvars_=%eval(&_nvars_+1); %let _var_=%qscan(%quote(&syspbuff), &_nvars_, %str( (),)); %if &_nvars_ eq 1 %then %let _vars_="%upcase(%trim(&_var_))"; %else %let _vars_=&_vars_, "%upcase(%trim(&_var_))"; %end; proc sql noprint; select name into: _mvars_ separated by ',' from sashelp.vmacro where scope='GLOBAL' and upcase(name) in (&_vars_); select name into: _uvars_ separated by '", "' from sashelp.vmacro where scope ne 'GLOBAL' and upcase(name) in (&_vars_); quit; %if (%length(&_mvars_) >1) %then %do; %let _nvars_=0; %do %while(%length(%nrbquote(%qscan(%quote(&_mvars_), %eval(&_nvars_+1), %str(,))))); %let _nvars_=%eval(&_nvars_+1); %let _mvar_=%qscan(%quote(&_mvars_), &_nvars_, %str(,)); %put --> Note: System is deleting global macro variable "&_mvar_".; %symdel &_mvar_; %end; %end; %else %do; %put ==> Alert! Cannot find global macro variables &_vars_!; %end; %if (%length(&_uvars_)>2) %then %do; %put ==> Alert! System macro variables "&_uvars_" cannot be deleted!; %end; %let syslast=&_tmplast_; %mend _delmvar_;